﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using log4net;
using RealState.BusinessObjects;
using RealState.BLL;
using System.Collections.Generic;

namespace RealState.W.Services
{
    /// <summary>
    /// Summary description for ContentService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [System.Web.Script.Services.ScriptService()]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ContentService : System.Web.Services.WebService
    {
        private VwContentsBLL contentsBLL;
        private List<VwContents> listContent;
        protected ILog log = LogManager.GetLogger("ListContents");

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [System.Web.Services.WebMethod]
        public List<VwContents> GetContent(string cid)
        {
            contentsBLL = new VwContentsBLL();
            try
            {
                if (!cid.Equals("8"))
                    listContent = contentsBLL.GetViewContents().Where(v => v.CategoryId == Convert.ToInt32(cid)).ToList();
                else
                    listContent = contentsBLL.GetViewContents().Where(v => v.CategoryId == 9 || v.CategoryId == 10).ToList();
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
            }
            finally
            {
                contentsBLL = null;
            }
            return listContent;
        }
        
    }
}
